import { TokenType } from './token_type';

/**
 * Token代表的是一段有意义的字符序列,长度不定.
 */
export class Token {
  /// <summary>
  ///     Type
  /// </summary>
  public type: TokenType;

  /// <summary>
  ///     Key
  /// </summary>
  public key: string;

  /// <summary>
  ///     True when the token has a param
  public hasParam: boolean;

  /// <summary>
  ///     Param value
  /// </summary>
  public param: number

  /// <summary>
  ///     True when the token contains text
  /// </summary>
  isTextToken(): boolean {
    return this.type == TokenType.Text;
  }

  public constructor() {
    this.type = TokenType.None;
    this.param = 0;
  }
}